package org.util.properties;

import org.jdom.Element;

/**
 * 
 * 获取messages.xml提示文件相应的提示信息;
 * 
 * @Title: Messager.java
 * @Description:培训师平台
 * @Copyright: Copyright (c) 2011
 * @Company:北京千家在线
 * @author miaoyouhu
 * @date Jul 1, 2011 10:27:53 AM
 * @version V1.0
 */
public class Messager extends XMLProcessor {
	private static Messager instance = null;

	private Messager(String filePath) throws Exception {
		super(filePath);
	}

	public static synchronized Messager getInstance() throws Exception {
		if (instance == null) {
			FileProperties fileproperties = new FileProperties(
					"/configure.properties");
			instance = new Messager(fileproperties.getProperty("promptMsg"));
		}
		return instance;
	}

	public String getMsg(String key) {
		Element element = getElement(this.root, "Key", key);
		if (element == null)
			return "系统内部错误！";
		return element.getAttributeValue("Value");
	}

	// 测试
	public static void main(String[] args) throws Exception {
		String mes = Messager.getInstance().getMsg("user_idea_success");
		System.out.println(mes);
	}
}
